<template>
	<view class="list">
		<!-- 背景图绑定 -->
		<view class="fixbg" :style="{backgroundImage:'url('+playlist.coverImgUrl+')'}"></view>
		<musichead title="歌单" :icon="true"></musichead>
		<view class="container">
			<scroll-view scroll-y="true">
				<!-- 头部 -->
				<view class="list-head">
					<!-- 图片 -->
					<view class="list-head-img">
						<image :src="playlist.coverImgUrl"></image>
						<!-- 小播放按钮 -->  <!-- 过滤器 -->
						<text class="iconfont">&#xe624;{{playlist.playCount | formatCount}}</text>
					</view>
					
					<!-- 图片右侧文字区域 -->
					<view class="list-head-text">
						<view>{{playlist.name}}</view>
						<view>
							<image :src="playlist.creator.avatarUrl"></image>{{playlist.creator.nickname}}
						</view>
						<view>{{playlist.description}}</view>
					</view>
					
				</view>
				<!-- 分享 -->
				<!--  下列注释表示该端代码只会出现在微信小程序端  h5端不显示 -->
				<!-- #ifdef  APP-PLUS -->
				<button open-type="share" class="list-share">
					<text class="iconfont">&#xe6a5;</text>分享给微信好友
				</button>
				<!-- #endif -->
				
				
				<!--  歌单布局 -->
				<view class="list-music">
					<!-- 头部 -->
					<view class="list-music-head">
						<text class="iconfont">&#xe624;</text>
						<text>播放全部</text>
						<text>共({{playlist.trackCount}})首</text>
					</view>
					<!-- 列表部分 -->
					<view class="list-music-item" v-for="(item,index) in playlist.tracks" :key="index" @tap="handToDetail(item.id)">
						<view class="list-music-top">{{index+1}}</view>
						<view class="list-music-song">
							<view>{{item.name}}</view>
							<!-- 歌曲独家 -->
							<view>
								<!--  privileges属性中的对象中的maxbr=999000为sq   目前所有歌曲都是这个值，按照你的想法找一个字段来判断 -->
								<image v-if="privileges[index].maxbr=999000" src="../../static/sq.png" mode=""></image>
								
								<image v-if="privileges[index].flag>60 && privileges[index].flag<70 " src="../../static/dujia.png"></image>
								<!-- 歌手名-专辑名 -->
								{{item.ar[0].name}} - {{item.al.name}}
							</view>
						</view>
						<!-- 播放按钮 -->
						<text class="iconfont">&#xea6e;</text>	
					</view>
					
					
					
					
				</view>
				
				
			</scroll-view>
			
		</view>
	</view>
</template>

<script>
	//引入图标字体
	import '@/common/iconfont.css'
	//引入头部组件
	import musichead from '../../components/music-head/music-head.vue'
	//引入请求 
	import {list} from '../../common/api.js'
	export default {
		data() {
			return {
				playlist:{
					description:'',//描述
					name:'',//榜单名
					coverImgUrl:'',//背景图
					creator:{
						avatarUrl:'',//背景图旁云音乐图标
						nickname:''//名称
						
					},
					tracks:[]//歌曲列表
					
				},
				privileges:[]
				
			}
		},
		onLoad(options) {
			//{ "id": "19723756"}
			console.log(options.id
			)
			//得到id  options.id
			list(options.id).then((res)=>{
				//console.log(res)
				//将结果赋值给本地对象playlist
				this.playlist=res.data.playlist
				//console.log(this.playlist)
				//独家权限数据 赋值
				this.privileges=res.data.privileges
				//console.log(this.privileges)
			})
		},
		
		components:{
			musichead
		},
		
		methods: {
			//携带歌曲id跳转
			handToDetail(songId){
				console.log(songId)
				uni.navigateTo({
					//传递到detail页面
					url:'/pages/detail/detail?songId='+songId
				})
			}
		}
	}
</script>

<style>
	/* 列表头部样式 */
		.list-head {
			display: flex;
			margin: 30rpx;
		}
	
		.list-head-img {
			width: 265rpx;
			height: 265rpx;
			border-radius: 15rpx;
			margin-right: 40rpx;
			overflow: hidden;
			position: relative;
		}
	
		.list-head-img image {
			width: 100%;
			height: 100%;
		}
	
		.list-head-img text {
			position: absolute;
			font-size: 26rpx;
			color: white;
			right: 8rpx;
			top: 8px
		}
	
		.list-head-text {
			flex: 1;
			font-size: 24rpx;
			color: #c3d1e3;
		}
	
		.list-head-text image {
			width: 52rpx;
			height: 52rpx;
			border-radius: 50%;
		}
	
		.list-head-text view:nth-child(1) {
			font-size: 34rpx;
			color: #ffffff
		}
	
		.list-head-text view:nth-child(2) {
			display: flex;
			align-items: center;
			margin: 30rpx 0;
		}
	
		.list-head-text view:nth-child(2) text {
			margin-left: 15rpx;
		}
	
		.list-head-text view:nth-child(3) {
			line-height: 38rpx;
		}
		/* 分享按钮 */
		.list-share{ width:330rpx; height:72rpx; margin:0 auto; background:rgba(0,0,0,0.4); text-align:center; line-height: 72rpx; font-size:26rpx; color:white; border-radius: 36rpx;}
		.list-share text{ margin-right:15rpx;}
		
		/* 歌曲列表区域 */
		.list-music{ background: white;border-radius: 50rpx;margin-top: 40rpx; overflow: hidden;}
		.list-music-head{height: 50rpx; margin: 30rpx 0 70rpx 22rpx;}
		.list-music-head text:nth-child(1){height: 50rpx; font-size: 50rpx;}
		.list-music-head text:nth-child(2){font-size: 30rpx; margin: 0 10rpx 0 26rpx;}
		.list-music-head text:nth-child(3){font-size: 26rpx;color: #b2b2b2;}
		.list-music-item{display: flex;margin: 0 32rpx 66rpx 22rpx;align-items: center;color:
		#959595;}
		.list-music-top{width: 58rpx; font-size: 30rpx;line-height: 30rpx;}
		.list-music-song{flex: 1;}
		.list-music-song view:nth-child(1){font-size: 28rpx;color: black;}
		.list-music-song view:nth-child(2){display: flex; font-size: 20rpx; align-items: center;}
		.list-music-song view:nth-child(2) image{width:32rpx;height: 20rpx;margin-right: 10rpx;}
		.list-music-item text{font-size: 50rpx;color: #c7c7c7;}
</style>
